package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import service.CaCheService;
import service.ShortMessageService;
import util.ResponseBean;
import util.phone_get;

import javax.annotation.Resource;

@Controller
public class ShortMessage {
    @Resource
    CaCheService caCheService;

    @Resource
    ShortMessageService shortMessageService;

    @GetMapping("/phone/Code")
    @ResponseBody
    public ResponseBean pgone_get_code(String phone) throws Exception {

        ResponseBean responseBean=null;

        //发送短信成功则返回验证码 反之则返回null
        String code=shortMessageService.Get_Verification_Code(phone, phone_get.password);

        //存入缓存
        responseBean=caCheService.outPhoneCode(phone,code);

        return responseBean;
    }
}
